package cn.hesion.leetcode;
/**
 * ClassName: RecentCounter <br/>
 * Description: <br/>
 * date: 2022/5/17 5:48<br/>
 *
 * @author Hesion<br />
 * @version
 * @since JDK 1.8
 */

import java.util.ArrayDeque;
import java.util.Queue;

/**
 * @author: hesion
 * @create: 2022-05-17 05:48
 **/
public class RecentCounter {
    Queue<Integer> queue;

    public RecentCounter() {
        queue = new ArrayDeque<>();
    }

    public int ping(int t) {
        queue.offer(t);
        while (queue.peek() < t - 3000) {
            queue.poll();
        }
        return queue.size();
    }

    public static void main(String[] args) {

//        new RecentCounter().ping()
    }
}
